import { R_tableData, R_add, R_update, R_remove } from "@/utils/tableData";



import request from '@/utils/request'

export const A_tableData = function(data) {
    return R_tableData({
        method: 'post',
        url: '/SciDcr/list',
        data,
    })
}


export const A_add = function(data) {
    return R_add({
        method: 'post',
        url: '/SciDcr/add',
        data
    })
}


export const A_update = function(data) {
    return R_update({
        method: 'post',
        url: '/SciDcr/update',
        data
    })
}

export const A_remove = function(ID) {
    return R_remove({
        method: 'post',
        url: '/SciDcr/delete',
        data: {
            dcrKey: ID
        }
    })
}


export const A_check_T = async function(data) {
    let result = await request({
        method: 'post',
        url: '/SciDcr/Tshen',
        data,
    })
    return result
}


export const A_check_F = async function(data) {
    let result = await request({
        method: 'post',
        url: '/SciDcr/Nshen',
        data,
    })
    return result
}

/**
 * 下载表格
 * @param {*} data 
 * @returns 
 */
export const A_downLoadExcel = async function() {
    let res = await request({
        method: 'post',
        url: '/SciDcr/downloadExcel',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}

/**
 * 获取个人附件
 * @param {*} dcrKey 唯一标识
 */
export const A_getFile = async function(dcrKey) {
    let res = await request({
        method: 'post',
        url: '/SciDcr/Perfile',
        data: {
            dcrKey
        }
    })
    return res
}

/**
 * 获取一级等级
 * @returns 
 */
export const A_getLevel1 = async function() {
    let res = await request({
        method: 'get',
        url: '/SciDcr/Level'
    })
    return res
}


/**
 * 
 * @param {*} dcrnCcategory 一级等级
 * @returns 
 */
export const A_getLevel2 = async function(dcrnCcategory) {
    let res = await request({
        method: 'post',
        url: '/SciDcr/getLevel',
        data: {
            dcrnCcategory
        }
    })
    return res
}

/**
 * 
 * @param {*} dcrnLevel 二级等级
 * @returns 
 */
export const A_getLevel3 = async function(dcrnLevel) {
    let res = await request({
        method: 'post',
        url: '/SciDcr/getRange',
        data: {
            dcrnLevel
        }
    })
    return res
}

export const A_downLoadExample = async function() {
    let res = await request({
        method: 'get',
        url: '/SciDcr/downloadExcelExample',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}